package pref.junx.flybird.activity.grou_msg;

import android.content.Intent;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.ArrayList;
import java.util.List;

import pref.junx.flybird.R;
import pref.junx.flybird.activity.main.NewMainActivity;
import pref.junx.flybird.adapter.SimpleAdapter_fri;
import pref.junx.flybird.base.BaseActicvitylhy;
import pref.junx.flybird.entity.User_idea;
import pref.junx.flybird.tools.JumpUtil;


/**
 * Created by 半生瓜 on 2017/8/7.
 */

public class Grou_msg_Actvity extends BaseActicvitylhy<Grou_msg_Presenter, Grou_msg_Model> implements Grou_msg_Conteact.View {
    private DefaultItemAnimator animator;
    TextView watch_group_nickname,watch_group_value;
    Button watch_group_event,out_group_call;
    RecyclerView recyclerView;
    int id;
    String group_name;
    String group_value;
    private SimpleAdapter_fri adapter;
    List<User_idea> userIdeas= new ArrayList<>();
    @Override
    public int getLayoutId() {
    return R.layout.watch_group_layout;    }

    @Override
    public void initview() {
        watch_group_nickname=(TextView)findViewById(R.id.watch_group_nickname);
        watch_group_value=(TextView)findViewById(R.id.watch_group_value);
        watch_group_event=(Button) findViewById(R.id.watch_group_event);
        out_group_call=(Button) findViewById(R.id.out_group_call);
        recyclerView=(RecyclerView) findViewById(R.id.recyclerview_gro);
        watch_group_event.setOnClickListener(this);
        out_group_call.setOnClickListener(this);
    }

    @Override
    public void processClick(View view) {


    }


    @Override
    public void init() {
        Intent intent = getIntent();
        id = intent.getIntExtra("id",0);
        group_name= intent.getStringExtra("name");
        group_value= intent.getStringExtra("value");
        watch_group_nickname.setText(group_name);
        watch_group_value.setText(group_value);
        presenter.getUser(id);

    }





    @Override
    public void success() {

    }

    @Override
    public void result(String a) {

    }

    @Override
    public void susses() {
        t.show_l("删除成功");
        NewMainActivity.newMainActivity.finish();
        JumpUtil.to(c,NewMainActivity.class);
        finish();
    }

    @Override
    public void fail() {
        t.show_l("删除失败");
        NewMainActivity.newMainActivity.finish();
        JumpUtil.to(c,NewMainActivity.class);
        finish();
    }

    @Override
    public void setUserMsg(List<User_idea> data) {
        userIdeas=data;
        recyclerView.setHasFixedSize(true);
        recyclerView.setItemAnimator(animator);
        recyclerView.setLayoutManager(new LinearLayoutManager(c));
        adapter = new SimpleAdapter_fri(c, userIdeas);
        recyclerView.setAdapter(adapter);
    }
}


